package com.zhaojiyuan.boot.base.common.bean.rest;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

@Setter
@Getter
@Accessors(chain = true)
public class RestResult<T> {

  private final static int SUCCESS_CODE = 200;

  private final static String SUCCESS_MSG = "请求数据成功";

  private int code;

  private String msg;

  private T data;

  private RestResult() {
  }

  public static RestResult success() {
    return new RestResult<>().setCode(SUCCESS_CODE).setMsg(SUCCESS_MSG);
  }

  public static <T> RestResult<T> success(T data) {
    return success().setData(data);
  }

}
